<template>
  <div>
    <ul v-for="i in wenz">
      <li>
        名：{{ i.name }}---内容：{{ i.content }}
        <ul>
          <li v-for="j in com" v-if="i.id==j.wid">{{ j.comment }}</li>
          <van-button round @click="add(i.id)">评论</van-button>
        </ul>
      </li>
    </ul>

  </div>
</template>

<script>
export default {
  name: "show_wenz",
  data() {
    return {
      wenz: [],
      com: [],
      wenid: localStorage.getItem('wenid')
    }
  },
  methods: {
    get_wenz() {
      this.$axios.get('/wenz/wenz')
        .then(res => {
          this.wenz = res.data.list
        })
    },
    add(id) {
      if (this.wenid) {
        this.$router.push({path: '/com_wenz', query: {'id': id}})

      } else {
        alert('未登录')
        this.$router.push('/login_wenz')
      }
    },
    get_com() {
      this.$axios.get('/wenz/com')
        .then(res => {
          this.com = res.data.list
        })

    }
  },
  mounted() {
    this.get_wenz()
    this.get_com()
    // localStorage.setItem('wenid','')
  }
}
</script>

<style scoped>

</style>
